package com.ruoyi.common.core.resource;

import java.security.InvalidParameterException;

/**
 * @Description:
 * @Company: 北京卡拉卡尔股份技术有限公司
 * @Author: Darren Ho
 * @Date: 10/10/2020 09:59
 */
public final class OperatorUserSystemHolder {

    private static final ThreadLocal<OperatorUserSystem> OPERATOR_USER_SYSTEM_THREAD_LOCAL = new ThreadLocal<>();

    private OperatorUserSystemHolder() {
    }

    public static void clear() {
        OPERATOR_USER_SYSTEM_THREAD_LOCAL.remove();
    }

    public static OperatorUserSystem get() {
        return OPERATOR_USER_SYSTEM_THREAD_LOCAL.get();
    }

    public static void set(OperatorUserSystem operatorUserSystem) {
        if (operatorUserSystem == null) {
            throw new InvalidParameterException("Only non-null operator user system  is permitted");
        }
        OPERATOR_USER_SYSTEM_THREAD_LOCAL.set(operatorUserSystem);
    }

}
